<?php

    class Model_Email extends Zend_Mail{

    	public function __construct(){
    		parent::__construct('UTF-8');
    		$this->setDate(date("d.m.Y H:i:s"));

    	}

    	public function clearAll(){
            $this->clearFrom();
            $this->clearSubject();
            $this->clearRecipients();
    	}

    	public function sendMail($params){
            $this->clearAll();

            //[fe_user_nid] => 8
//            [fe_user_firstname] => al
//            [fe_user_lastname] => krug
//            [fe_user_email] => ak187@weboages.de
//            [fe_user_password] => 9577a2f4a686ebba5ddf41d79436eaeb
//            [deleted] => 0
//            [registered] => 0
//            [created] => 2012-06-04 14:29:52
//            [role] => fe_user

            $this->setSubject($this->parseContent(file_get_contents (BOOTSTRAP_EMAIL_PATH.'mailToCustomerSubject.txt'), $params));
    		$this->setBodyText($this->parseContent(file_get_contents (BOOTSTRAP_EMAIL_PATH.'mailToCustomerBody.txt'), $params));
    		//$this->setBodyHtml($this->parseContent(file_get_contents (BOOTSTRAP_EMAIL_PATH.'mailToClinicBodyHtml.txt'), $variables));
    		$this->setFrom('info@oncut.de', 'ONCUT');
    	    if('production' == APPLICATION_ENV){             
   			    //$this->addTo();
            }else{
                $this->addTo('akrug@webpages.de', 'al');
            }

			$this->send();
    	}

    	public function parseContent($content, $variables){

    		//fuege baseurl hinzu
    		$variables['BASE_URL'] = Zend_Registry::get('uri');

    		foreach ($variables as $vIndex => $v){
                $content = str_replace('###'.$vIndex.'###', $v, $content);
    		}
    		return $content;
    	}
    }